﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Moq;

namespace _028接口_依赖反转_单元测试3_单元测试.Test
{
    [TestClass]
    public class DeskFanTest
    {
        [TestMethod]
        public void PowerLowerThanZero_OK()
        {
            var fan = new DeskFan(new PowerSupplyLowerThanZero());
            var expected = "slow";
            var actual = fan.Work();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void PowerLowerThan200_OK()
        {
            var mock = new Mock<IPowerSupply> ();
            mock.Setup(ps => ps.GetPower()).Returns(() => 0);
             var fan = new DeskFan(mock.Object);
            var expected = "Explode!";
            var actual = fan.Work();
            Assert.AreEqual(expected, actual);
        }

    }

    class PowerSupplyLowerThanZero : IPowerSupply
    {
        public int GetPower()
        {
            return 0;
        }
    }

    class PowerSupplyHigerThan200 : IPowerSupply
    {
        public int GetPower() {
            return 220;
        }
    }
}